package com.dhf.framework.system.service;


import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhf.framework.base.mybatis.core.dao.GenericDao;
import com.dhf.framework.base.mybatis.core.service.GenericService;
import com.dhf.framework.system.dao.SysDictDataDao;
import com.dhf.framework.system.dao.SysDictTypeDao;
import com.dhf.framework.system.entity.SysDictData;
import com.dhf.framework.system.entity.SysDictType;

/**
 * 描述：</b>SysDictDataService<br>
 * @author：minstar
 * @since：2017年02月22日 21时26分09秒 星期三 
 * @version:1.0
 */
@Service
public class SysDictDataService extends GenericService<SysDictData,Long>{
	
	public final Logger    logger  = LoggerFactory.getLogger( this.getClass() );

	@Autowired
	private SysDictTypeDao sysDictTypeDao;
	
	@Autowired
	private SysDictDataDao sysDictDataDao;

    
    @Override
    public GenericDao<SysDictData, Long> getMyBatisGenericDao() {
        return sysDictDataDao;
    }
    /**
     * 
    * @Description: 根据字典类型编码typeCode查询typeId，再查询该编码下所有数据集
    * @param @param typeCode
    * @param @return    设定文件
    * @return List<SysDictData>    返回类型
     */
    public List<SysDictData> queryByTypeCode(String typeCode){
    	SysDictType sysDictType=new SysDictType();
		sysDictType.setTypeCode(typeCode);
		List<SysDictType> list=this.sysDictTypeDao.query(sysDictType);
		SysDictData sysDictData=new SysDictData();
		if(!list.isEmpty()){
			SysDictType entity=list.get(0);
			sysDictData.setTypeId(entity.getTypeId());
		}
		return this.query(sysDictData);
    }
    
    public List<SysDictData> queryDataContent(String typeCode,String dataCode){
    	SysDictType sysDictType=new SysDictType();
		sysDictType.setTypeCode(typeCode);
		List<SysDictType> list=this.sysDictTypeDao.query(sysDictType);
		SysDictData sysDictData=new SysDictData();
		if(!list.isEmpty()){
			SysDictType entity=list.get(0);
			sysDictData.setTypeId(entity.getTypeId());
			sysDictData.setDataCode(dataCode);
		}
		return this.query(sysDictData);
    }
}

